<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>06-展开运算符</title>
  </head>
  <body>
    <script>
      // 展开运算符：将一个数组/对象进行展开，咱们先讲展开数组
      //  1. 基本使用，不修改原数组
      const arr = [1, 2, 3, 'song', true, { name: 'sjl', age: 18 }]
      console.log(arr) // [1, 2, 3]
      console.log(...arr) // 1 2 3

      //  2.使用场景：求数组最大值/最小值，数组合并
      const arr1 = [2, 78, 13, 89, 15, 5]
      console.log(Math.max(...arr1)) // 89
      console.log(Math.min(...arr1)) // 2

      // 合并数组  
      const a1 = [7, 4, 2]
      const a2 = [9, 24, 24]
      console.log([a1, a2])
      console.log([...a1, ...a2]) // [7, 4, 2, 9, 24, 24]
      
      
    </script>
  </body>
</html>
